﻿/*
 * Vytvořeno aplikací SharpDevelop.
 * Uživatel: lebeda
 * Datum: 29.5.2012
 * Čas: 21:10
 * 
 * Tento template můžete změnit pomocí Nástroje | Možnosti | Psaní kódu | Upravit standardní hlavičky souborů.
 */
using System;
using System.Windows.Forms;
//using System.Diagnostics;

using CommandLine;

//using System.Runtime.InteropServices;

namespace locateGUI
{
    /// <summary>
    /// Class with program entry point.
    /// </summary>
    internal sealed class Program
    {
        
//        [DllImport("user32.dll")]
//        static extern bool SetForegroundWindow(IntPtr hWnd);
//
//        static bool ActivateApplicationAlreadyRunning()
//        {
//            string proc = Process.GetCurrentProcess().ProcessName;
//            Process[] processes = Process.GetProcessesByName(proc);
//            if (processes.Length < 2) return (false);
//            foreach (Process process in processes)
//            {
//                if (process.Id != Process.GetCurrentProcess().Id)
//                {
//                    SetForegroundWindow(process.MainWindowHandle);
//                    return (true);
//                }
//            }
//            return false;
//        }
        
        /// <summary>
        /// Program entry point.
        /// </summary>
        [STAThread]
        private static void Main(string[] args)
        {
            // if (ActivateApplicationAlreadyRunning()) return;
            
            CmdOptions options = new CmdOptions();
            //            if (args.Length > 0) {
            if (!CommandLineParser.Default.ParseArguments(args, options)) {
                System.Environment.Exit(0);
            }
            //            }
            
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm mainForm = new MainForm();
            mainForm.options = options;
            
            Application.Run(mainForm);
        }
        
    }
}
